Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@hig/theme-data
Advanced tools
HIG theme data is a representation of the HIG visual design language in the form of data.
yarn add @hig/theme-data
import lightGrayMediumDensityTheme from '@hig/theme-data/build/json/lightGrayMediumDensityTheme/resolvedRoles.json';
console.log(lightGrayMediumDensityTheme);
// {
// "basics.borderRadii.none": "0",
// "basics.borderRadii.small": "0"
// "basics.borderRadii.medium": "2px"
// ...
// }
import resolvedRoles from '@hig/theme-data/build/json/lightGrayMediumDensityTheme/resolvedRoles.json';
import unresolvedRoles from '@hig/theme-data/build/json/lightGrayMediumDensityTheme/unresolvedRoles.json';
import { extendTheme, resolveTheme } from '@hig/theme-data';
const redAccentedUnresolvedTheme = extendTheme(unresolvedRoles, {
"colorScheme.accentColor": "#F00",
});
const redAccentedTheme = resolveTheme(redAccentedUnresolvedTheme);
console.log(redAccentedTheme);
// {
// ...
// "colorScheme.accentColor": "#F00",
// "input.focus.borderBottomColor": "#F00"
// ...
// }
@import "@hig/theme-data/build/scss/_lightGrayMediumDensityTheme.scss";
.my-component {
background-color: $colorScheme-surfaceLevel10Color;
color: $colorScheme-textColor;
}
A theme is comprised of many, many roles. Each roles defines the meaning of a value in the design system. Consider the following role—colorScheme.textColor
. This roles describes the default color of text in the design system. The value for a role may vary from theme to theme. For example, a theme with a light gray color scheme may provide the value "#3c3c3c"
. A theme with a dark blue color scheme may provide the value "#f5f5f5"
.
A component can be made themable by styling it using theme data roles rather than hard-coded values.
Roles fall into 3 broad categories—basic roles, dimension roles, and component roles.
Basics are named values (colors, spacings, typographic specifications, etc.) from which (very nearly) all other values in a theme are derived. Basics do not change from theme to theme.
Each themes presently has two dimensions—a color scheme, and a density.
Color scheme roles define roles related to color that change from theme to theme. They apply to many components.
A few examples of color scheme roles:
colorScheme.textColor
: The default color for text throught a theme. Value will be dark in a ligher theme, and light in a dark theme to contrast with surface colors.colorScheme.surfaceLevel10Color
: The most prominant background color for containers in the theme. Will be lighter in a light theme, darker in a darker theme.colorScheme.accentColor
: A bold color used to provide emphasis in the theme.Density roles are reoles related to information density. They change from theme to theme.
A couple of examples of density roles:
density.fontSizes.medium
: Text size for body copy in an app. Value will be smaller in a high-density theme.density.spacing.medium
: A width of space between elements. Will be smaller in a high-density theme, larger in a lower-desnity theme.Component roles defined every property needed to express the design for a component in all of its states.
A few examples of component roles
button.outline.borderColor
: The default border color for an outline variant buttonbutton.outline.hover.borderColor
: The border color of a button when the mouse is above itbutton.outline.focus.borderColor
: The border color of a button when it has keyboard focusValues in a theme may take two forms. They may be a basic value in string format (e.g. "#0696d7" or "4px") or a value may be a reference to another value. For example, textArea.focus.borderBottomColor
may refer to colorScheme.accentColor
, which refers to basics.colors.autodeskBlue600
. Theme data source code is stored in a format that represents these relationships. These relationships are rarely needed in product, so we resolve the relatinships into a flat list of values for typical use.
An unresolved role defines a primitive value or a reference to another role in the system.
Here are some unresolved roles:
basics.colors.autodeskBlue500: {
type: "color", // Type is used to validate values and create documentation at development time
value: "#0696d7" // This is a primitive value
},
colorScheme.accentColor: {
type: "color",
value: { // This is a reference to another value
ref: "basics.colors.autodeskBlue500"
}
},
A resolved role defines a primitive value (e.g. “#0696D7” or “16px”) in the theme system.
Here are the two previous roles after being resolved:
basics.colors.autodeskBlue500: "#0696d7",
colorScheme.accentColor: "#0696d7", // Value has been resolved to equal basics.colors.autodeskBlue500
FAQs
HIG Theme Data
We found that @hig/theme-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.